<template>
    <div class="menu_outer">
        <div class="menu">
            <div>
                <div class="fix_m">
                    <div @click="goPage('/interact')" :class="{ active: path.includes('/interact') }"> 互动</div>
                    <div @click="goPage('/highQuality')" :class="{ active: path.includes('/highQuality') }"> 严选</div>
                    <div @click="goPage('/shareClub/list')" :class="{ active: path.includes('/shareClub') }">私享会</div>
                    <div @click="goPage('/Ranking')" :class="{ active: path.includes('/Ranking') }"> 排行榜</div>
                    <div @click="goPage('/firendCircle')" :class="{ active: path.includes('/firendCircle') }">朋友圈</div>
                    <div @click="goPage('/association/youping')" :class="{ active: path.includes('/association') }"> 我的
                    </div>
                </div>
                <div class="list">
                    <div v-for="item in $store.state.leftmenu" :key="item.id" @click="goSearch('/searchHome', item.id)">
                        {{ item.name }}
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    name: "leftMenu",
    data() {
        return {
            list2: []
        }
    },
    props: {
        list: {
            type: Array, default: () => {
                return []
            },
        }
    },
    computed: {
        path() {
            return this.$route.path
        }

    },
    // 监听prop中的值
    watch: {
        list(n) {


        }

    },
    mounted() {
        let myleft = this.$store.state.leftmenu
        if (myleft.length == 0) {
            this.getLeft()
        }

    },
    methods: {
        goSearch(url, id) {
            if (id) {
                // 另页打开
                const route = this.$router.resolve({
                    path: url,
                    query: { id }
                });
                window.open(route.href, '_blank');
            }
        },
        // 社群互动
        getLeft() {
            this.$api.getLeft().then(res => {
                console.log(res)
                if (res.data.code == 1) {

                    this.$store.commit('setLeftmenu', res.data.data)
                }
            })
        },

        // 点击跳转外部链接
        gourl(url) {
            if (url) {
                window.open(url, '_blank', 'noopener,noreferrer');
            }
        },
        goPage(url) {
            console.log(this.path, url);

            if (this.path != url) {
                this.$router.push(url)
            }
        },
    },
}
</script>
<style lang="scss" scoped>
.menu_outer {
    width: 9.38rem;
    height: 100%;
    padding: 0 1px;
}

.menu {
    width: 9.38rem;
    height: calc(100vh - 128px);
    background: #E7F1FE;
    padding: 30px 1.15rem;
    position: -webkit-sticky;
    left: 8.33rem;
    position: sticky;
    top: 0;

    >div {
        position: sticky;
        top: 128px;
    }

    .fix_m {

        >div {
            cursor: pointer;
            margin-bottom: .8rem;
            font-weight: 400;
            font-size: 1.25rem;
            color: #333333;

            &:hover {
                color: #1068E7;
            }
        }
    }

    .list {
        border-top: 0.01rem solid #CCCCCC;
        padding-top: 1.51rem;

        >div {
            cursor: pointer;
            margin-bottom: .8rem;
            font-weight: 400;
            font-size: 1.25rem;
            color: #333333;

            &:hover {
                color: #1068E7;
            }
        }
    }
}

.active {
    color: #1068E7 !important;
    font-weight: bold !important;
}
</style>
